var setting = {
    view: {
        dblClickExpand: false,
        showLine: true,
        selectedMulti: false
    },
    data: {
        simpleData: {
            enable:true,
            idKey: "id",
            pIdKey: "pId",
            rootPId: ""
        }
    },
    callback: {
        onClick: function(event, treeId, treeNode, treeFlag){
            $('tbody').addClass('app-hidden');
            var id = treeNode.id;
            switch(id){
                case 101:
                    $('#tbody1').removeClass('app-hidden');
                    break;
                case 102:
                    $('#tbody2').removeClass('app-hidden');
                    break;
                case 103:
                    $('#tbody3').removeClass('app-hidden');
                    break;
                case 104:
                    $('#tbody4').removeClass('app-hidden');
                    break;
                case 105:
                    $('#tbody5').removeClass('app-hidden');
                    break;
            }
        }
    }
};

var sysNodes = [
    { id:1, pId:0, name:"全部菜单", open:true},
    { id:101, pId:1, name:"资源管理"},
    { id:102, pId:1, name:"资源共享管理"},
    { id:103, pId:1, name:"资源目录"},
    { id:104, pId:1, name:"ETL管理"},
    { id:105, pId:1, name:"系统管理"}
];


$(document).ready(function(){
    var t1 = $("#sysTree");
    t1 = $.fn.zTree.init(t1, setting, sysNodes);


});

//更多查询条件  按钮 单击事件
$('#openMoreBtn').on('click',function(){
    //控制 收起图标 隐藏显示
    $('#shouqiImg')[0].classList.toggle('app-hidden');
    //控制 更多图标隐藏显示
    $('#gengduoImg')[0].classList.toggle('app-hidden');
    //控制 更多查询框 隐藏显示
    $('#otherQueryList')[0].classList.toggle('app-hidden');

});

//表格中 删除 按钮 事件绑定
$(".app-delete").on('click',function(){
    var that = this;
    layer.confirm('确定删除选中的数据？', {
        btn: ['确定','取消'] //按钮
    }, function(){
        //存储被删除的 tr

        var tr = that.parentNode.parentNode;
        tr.parentNode.removeChild(tr);
        //删除成功提示
        layer.msg('删除成功', {icon: 1});
    }, function(){

    });
});